home *** CD-ROM | disk | FTP | other *** search
- /* sort stuff */
- static char **gb_sort_array;
-
- static char **gb_t1;
- static char **gb_t2;
-
-
- /* case sensitive sort */
- /* ----------------- compare_ascii2() ------------------ Januaray 3, 1991 */
- int compare_ascii2(const void *t1, const void *t2)
- {
-
- gb_t1=(char **)t1;
- gb_t2=(char **)t2;
-
- return(strcmp(*gb_t1, *gb_t2));
- }
-
- // used to sort the file names
- /* ---------------------- str_array_sort() ------------- January 31,1992 */
- void str_array_sort(char **array, int max)
- {
- if ( max > 1 )
- {
- gb_sort_array=array;
- qsort(gb_sort_array, max, sizeof(char *), compare_ascii2);
- }
-
- }
-
-
- /* ----------------------- get_files() --------------------- April 9,1991 */
- int get_files(char *f_names[], char *file_mask, int attr)
- {
- int number_of_files;
- char path[100];
- struct ffblk fb;
-
-
- getcwd(path, 90);
- if ( *(path+strlen(path)-1) != '\\' )
- strcat(path, "\\");
- strcat(path, file_mask);
-
- memset((char *)&fb, 0, sizeof(fb));
- number_of_files=0;
- if ( !findfirst(path, &fb, attr) )
- {
- if ( !attr || fb.ff_attrib == attr )
- {
- if ( f_names[number_of_files] == NULL )
- f_names[number_of_files]=(char *)malloc(16);
- strcpy(f_names[number_of_files], fb.ff_name);
- ++number_of_files;
- }
-
- while ( !findnext(&fb) )
- {
- if ( !attr || fb.ff_attrib == attr )
- {
- if ( f_names[number_of_files] == NULL )
- {
- f_names[number_of_files]=(char *)malloc(16);
- if ( f_names[number_of_files] == NULL )
- {
- printf("\nout of mem coreleft() %u n %d\n", coreleft(), number_of_files);
- exit(1);
- }
- }
- strcpy(f_names[number_of_files], fb.ff_name);
- ++number_of_files;
- }
- }
- }
-
- // sort
- str_array_sort(f_names, number_of_files);
-
- return(number_of_files);
- }
-